<?php
namespace app\admin\controller;
use think\Db;
use think\Request;
class Rbac extends Base {

/**
 *权限控制类
*/
    //添加一个角色
    public function addRole(){ 
        return view();
    }

    //向数据库添加角色的完整信息
    public function addRoles(){
        $re = Request::instance()->post();
        $data = [
            'name' => $re['name'],
            'status' => $re['status'],
            'updated_time' => time(),
            'created_time' => time()
        ];
        $row = Db::table("role")->insert($data);
        if($row > 0){
            $this->success("添加成功",url('admin/rbac/addrole'),2);
        }else{
            $this->error("添加失败",url('admin/rbac/addrole'),2);
        }
    }

    //角色列表
    public function roleList(){
        $row = Db::table("role")->where("status = 0")->select();
        $this->view->assign("row",$row);
        return view();
    }

    //用户组列表
    public function userGroupList(){
        $row = Db::table("user")->where("status = 0")->select();
        $this->view->assign("row",$row);
        return view();

    }








}